import Vue from 'vue'
import VueRouter from 'vue-router'
import Layout from '@/views/layout/layout.vue'

Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    name: 'layout',
    component: Layout,
    children: [
      {
        path: '/',
        name: 'search',
        component: function () {
          return import('@/views/home/home.vue')
        },
        meta: {
          title: '主页'
        }
      },
      {
        path: '/catalogue',
        name: 'catalogue',
        component: function () {
          return import('@/views/catalogue/catalogue.vue')
        },
        meta: {
          title: '商品目录'
        }
      },
      {
        path: '/link-manager',
        name: 'link-manager',
        component: function () {
          return import('@/views/link-manager/link-manager.vue')
        },
        meta: {
          title: '链接管理'
        }
      },
      {
        path: '/order-manager',
        name: 'order-manager',
        component: function () {
          return import('@/views/order-manager/order-manager.vue')
        },
        meta: {
          title: '订单管理'
        }
      },
      {
        path: '/outbound',
        name: 'outbound',
        component: function () {
          return import('@/views/outbound/outbound.vue')
        },
        meta: {
          title: '中国出库'
        }
      },
      {
        path: '/overseas-in',
        name: 'overseas-in',
        component: function () {
          return import('@/views/overseas-in/overseas-in.vue')
        },
        meta: {
          title: '海外入库'
        }
      },
      {
        path: '/overseas-out',
        name: 'overseas-out',
        component: function () {
          return import('@/views/overseas-out/overseas-out.vue')
        },
        meta: {
          title: '海外出库'
        }
      },
      {
        path: '/script-run',
        name: 'script-run',
        component: function () {
          return import('@/views/script-run/script-run.vue')
        },
        meta: {
          title: '脚本运行'
        }
      },
    ]
  },
  {
    path: '/login',
    name: 'login',
    component: function () {
      return import('@/views/login/login.vue')
    }
  }
]

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})

export default router
